package Components.config
{
	import Components.image.ActionFileName;
	
	import flash.events.Event;
	import flash.net.SharedObject;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import mx.collections.ArrayCollection;

	public class ImageConfig
	{
		public static var total_bitmap:int = 0;
		
		public static var JSFL:String = "";
		public static function loadJsfl():void
		{
			var l:URLLoader = new URLLoader();
			l.addEventListener( Event.COMPLETE, function onLoaed( e:Event ):void{ JSFL = l.data as String; l.removeEventListener( Event.COMPLETE, onLoaed ); } );
			l.load( new URLRequest( "out.jsfl" ) );
		}
		
		/**
		 * 输出目录 
		 */		
		public static var out_dir:String = "";
		
		public static var outAS:String = "";
		public static var outBMDirArray:String = "";
		
		/**
		 * 动作播放间隔 
		 */		
		public static var duration:int = 120;
		/**
		 * 当前动作 
		 */		
		public static var currentAction:String = "站立";
		
		public static var xOffset:int = 0;
		public static var yOffset:int = 0;
		
		/**
		 * 上一个action
		 * 注：只在输出的时候有效 
		 */		
		public static var lastOutAction:String = "";
		
		/**
		 * 在主界面显示下的导出类名列表
		 * 注：其他地方没用，也不要引用
		 */		
		public static var arrOutBMClass:Array = [];
		
		public static function resetOffset():void
		{
			var arr:Array = _local.data.offset;
			if( arr != null )
			{
				xOffset = arr[0];
				yOffset = arr[1];
			}
		}
		
		private static var _local:SharedObject = SharedObject.getLocal("action_editor");
		public static function saveOffset():void
		{
			_local.data.offset = [xOffset, yOffset];
		}
		
		/**
		 * Setting里面调用
		 * 注：其他地方不要调用 
		 * @return 
		 * 
		 */		
		public static function getFileExportClass():Object
		{
			return _local.data.exportClass;
		}
		/**
		 * Setting里面调用
		 * 注：其他地方不要调用 
		 * @param arr
		 * 
		 */		
		public static function saveFileExportClass( obj:Object ):void
		{
			_local.data.exportClass = obj;
			
			ActionFileName.clearFileActions();
			var arr:ArrayCollection = obj as ArrayCollection;
			for( var i:int=0; i<arr.length; i++ )
			{
				var vo:Object = arr[i];
				ActionFileName.setFileActionName( vo.name, vo.clasz );
			}
			
			ActionEditor.instance.actionProvider = ActionFileName.fileActionProvider;
		}
		
		public static function initFileActionName():void
		{
			var arr:ArrayCollection = _local.data.exportClass as ArrayCollection;
			if( arr != null )
			{
				for( var i:int=0; i<arr.length; i++ )
				{
					var vo:Object = arr[i];
					ActionFileName.setFileActionName( vo.name, vo.clasz );
				}
			}
			ActionEditor.instance.actionProvider = ActionFileName.fileActionProvider;
		}
		
		public function ImageConfig()
		{
		}
	}
}